package ai.weed.qrcode.service;

import cn.hutool.json.JSONObject;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 订阅 服务
 *
 * @author zhong.wang
 * @date 2025/11/3
 **/
@Service
public class SubscribeService {

    @Resource
    private WxService wxService;

    public boolean sendMessage(String openid) throws Exception {
        JSONObject body=new JSONObject();
        body.set("touser","oDJhw15u1RKp-28P6UVxtfUGIVpc");
        body.set("template_id","QgRzcMFYHMTR47g4gnUW9mPgAtWFPJZYaF3KL5uZW7E");
        JSONObject json=new JSONObject();
        json.set("thing1",new JSONObject().set("value","氯唑沙宗片"));
        json.set("time2",new JSONObject().set("value","2027-01-02"));
        json.set("thing3",new JSONObject().set("value", 22));
        body.set("data",json);
        //发送
        String accessToken= wxService.getAccessToken();
        String post =  cn.hutool.http.HttpUtil.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken, body.toString());
        return true;
    }
}
